<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>审核管理</el-breadcrumb-item>
      <el-breadcrumb-item>实名认证列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <!--工具条-->
        <div style="display: flex; align-items: center">
          <span style="margin-right: 10rpx">审核状态：</span>
          <el-dropdown trigger="click" @command="searchDrow">
            <el-button type="primary" style="height:30px;padding:0 5px;">
              <span class="el-dropdown-link">
                {{
                  searchfrom.queryType == 0
                    ? "审核中"
                    : searchfrom.queryType == 1
                    ? "审核通过"
                    : searchfrom.queryType == 2
                    ? "拒绝"
                    : ""
                }}<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
            </el-button>

            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="0">审核中</el-dropdown-item>
              <el-dropdown-item command="1">审核通过</el-dropdown-item>
              <el-dropdown-item command="2">拒绝</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-row>

      <el-table
        ref="multipleTable"
        :data="userlist"
        border
        stripe
        style="width: 100%"
        @sort-change="changeSort"
        id="out-table"
        tooltip-effect="dark"
        @selection-change="handleSelectionChange"
      >
        <el-table-column prop="sellName" label="商城名称"></el-table-column>
        <el-table-column label="商城头像" width="100" prop="sellAvatar">
          <template slot-scope="scope">
            <el-image
              style="width: 60px; height: 60px; margin-bottom: 15px"
              :src="scope.row.sellAvatar"
              :preview-src-list="[scope.row.sellAvatar]"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="account" label="商城账号"></el-table-column>
        <el-table-column prop="area" label="地区"></el-table-column>
        <el-table-column prop="realAddr" label="地址"></el-table-column>
        <el-table-column prop="businessClass" label="主营业务"></el-table-column>

        <!-- <el-table-column label="身份证正面照片" width="100" prop="sfzImg">
          <template slot-scope="scope">
            <el-image
              style="width: 60px; height: 60px; margin-bottom: 15px"
              :src="scope.row.sfzImg"
              :preview-src-list="[scope.row.sfzImg]"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column label="身份证反面照片" width="100" prop="sfzReImg">
          <template slot-scope="scope">
            <el-image
              style="width: 60px; height: 60px; margin-bottom: 15px"
              :src="scope.row.sfzReImg"
              :preview-src-list="[scope.row.sfzReImg]"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column label="手持身份证照片" width="100" prop="selfImg">
          <template slot-scope="scope">
            <el-image
              style="width: 60px; height: 60px; margin-bottom: 15px"
              :src="scope.row.selfImg"
              :preview-src-list="[scope.row.selfImg]"
            ></el-image>
          </template>
        </el-table-column> -->

        <el-table-column prop="createTime" label="注册时间"></el-table-column>
        <!-- width="170" -->

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              v-if="scope.row.status == 0"
              size="mini"
              @click="showEditJiefeng(scope.row,0)"
              >通过</el-button
            >
            <el-button
              type="danger"
              v-if="scope.row.status == 0"
              size="mini"
              @click="showEditJiefeng(scope.row,1)"
              >拒绝</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchfrom.pageNo"
        :page-sizes="[2, 5, 10, 15]"
        :page-size="searchfrom.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  name: "realList",
  data() {
    return {
      searchfrom: {
        queryString: "",
        queryType: 0,
        pageNo: 1,
        pageSize: 10,
      },
      userlist: [],
    };
  },
  created() {
    this.getuserlist();
  },
  methods: {
    searchDrow(e) {
      console.log(e);
      this.searchfrom.queryType = e;
      this.searchfrom.pageNo = 1;
      this.getuserlist();
    },
    showEditJiefeng(item,status) {
      //let status = item.status;
      let text =
        status == 0
          ? "请确认是否确认通过商城认证审核?"
          : "请确认是否确认拒绝商城认证审核?";
      this.$confirm(text, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http
            .post("/manage/product/sellerVerify", {
              queryType: status == 0 ? 1 : 2,
              queryId: item.id,
              queryString: "",
            })
            .then((res) => {
              // console.log(res)
              if (res.data.status == 1) {
                this.$message({
                  message: status == 0 ? "已通过" : "已驳回",
                  type: "success",
                });

                this.getuserlist();
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },

    getuserlist() {
      this.$http.post("/manage/product/sellerList", this.searchfrom).then((res) => {
        // console.log(res)
        if (res.data.status == 1) {
          this.userlist = res.data.data.list;
          this.total = res.data.data.total;
        }
      });
    },
    searchUserList() {
      this.searchfrom.createDate = this.formatTime(this.value1);
      this.searchfrom.pageNo = 1;
      this.getuserlist();
    },
    // 监听 pagesize 的变化
    handleSizeChange(newSize) {
      // 把最新的 pagesize 赋值给 this.queryinfo
      this.searchfrom.pageSize = newSize;
      this.getuserlist();
    },
    // 监听 页码值 的变化
    handleCurrentChange(newPageNum) {
      console.log(newPageNum);
      this.searchfrom.pageNo = newPageNum;
      this.getuserlist();
    },
  },
};
</script>
